package com.shyroke.publish;


import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import com.shyroke.interceptor.MyLoginInteceptor;
import com.shyroke.service.ILogin;
import com.shyroke.service.Login;

public class PublishMain {
	public static void main(String[] args) {
		
		String address="http://localhost:3333/login";
		JaxWsServerFactoryBean factoryBean=new JaxWsServerFactoryBean();
		factoryBean.setAddress(address);
		factoryBean.setServiceClass(ILogin.class);
		factoryBean.setServiceBean(new Login());
		/**
		 * LoggingInInterceptor该拦截器类会在服务端被调用前打印日志
		 * LoggingOutInterceptor该拦截器类会在服务端被调用后打印日志
		 */
		factoryBean.getInInterceptors().add(new LoggingInInterceptor());
		factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
		/**
		 * 添加自定义拦截器，验证客户端发送的用户名和密码
		 */
		factoryBean.getInInterceptors().add(new MyLoginInteceptor());
		
		factoryBean.create();
		System.out.println("服务发布.......");
		
	}
}
